//
//  ViewController.m
//  UIButton
//
//  Created by liuchengming on 16/7/27.
//  Copyright © 2016年 liuchengming. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)CredteUIButton
{
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    btn.frame = CGRectMake(120 , 50, 80, 50);
    
    //正常状态的按钮
    [btn setTitle:@"按钮" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
    
    //改变状态的按钮
    [btn setTitle:@"按钮按下" forState:UIControlStateHighlighted];
    [btn setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted];
    
    //改变按钮的字体大小
    
    btn.titleLabel.font = [UIFont systemFontOfSize:20];
    
    
    btn.backgroundColor = [UIColor yellowColor];
    
    //btn.font = [UIFont systemFontOfSize:20];
    
    
    
    
    self.view.backgroundColor = [UIColor orangeColor];
    
    [self.view addSubview:btn];
}

- (void)CredteImageUIButton
{
    UIButton * imgbtn = [UIButton buttonWithType:UIButtonTypeCustom];
    
    imgbtn.frame = CGRectMake(100, 200, 40, 40);
    //imgbtn.backgroundColor = [UIColor blueColor];
    
    UIImage * icon1 = [UIImage imageNamed:@"1@2x"];
    UIImage * icon2 = [UIImage imageNamed:@"3@2x"];
    
    [imgbtn setImage:icon1 forState:UIControlStateNormal];
    
    [imgbtn setImage:icon2 forState:UIControlStateHighlighted];
    
    [self.view addSubview:imgbtn];
    
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    [self CredteUIButton];
    [self CredteImageUIButton];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
